﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="UsersManagement.aspx.cs" Inherits="Chinesys.UI.User.UsersManagement" %>

<%@ MasterType VirtualPath="~/Site.Master" %>
<%@ Register Src="../Controls/ValidationSummary.ascx" TagName="ValidationSummary"
    TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <link type="text/css" rel="Stylesheet" href="../Styles/CustomStyles.css" />
</asp:Content>
<asp:Content ID="UserManagementContent" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {

            $("a:contains('[Eliminar]')").click(
                function () {
                    return confirm('¿Esta seguro que desea eliminar al usuario?');
                }
            );

            if ($('#hdnBizRulesException').val().length > 0) {
                var text = $('#hdnBizRulesException').val();
                $('#hdnBizRulesException').val('');
                $('#modalText').text(text);

                $("#modal").overlay({
                    top: 260,
                    mask: {
                        color: '#fff',
                        loadSpeed: 200,
                        opacity: 0.5
                    },
                    closeOnClick: false,
                    load: true
                });

            }

        });
    </script>
    <div>
        <asp:Label ID="lblInfo" CssClass="labelinfo" runat="server" Visible="false" />
        <asp:HiddenField ID="hdnBizRulesException" runat="server" ClientIDMode="Static" />
        <uc1:ValidationSummary ID="validationSummary" runat="server" />
    </div>
    <div id="modal">
        <div>
            <h2>
                Mensaje del Sistema</h2>
            <p id="modalText">
            </p>
            <button class="close">
                Cerrar
            </button>
        </div>
    </div>
    <asp:Panel ID="pnlList" runat="server">
        <asp:LinkButton ID="btnNewUser" ForeColor="#4a3c8c" runat="server" Text="[Nuevo Usuario]"
            OnClick="btnNewUser_Click" />
        <br />
        <br />
        <div class="contentDiv">
            <asp:DataGrid ID="grdUsers" runat="server" AutoGenerateColumns="False" BackColor="White"
                Width="600px" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3"
                GridLines="Horizontal" OnItemCommand="grdUsers_ItemCommand">
                <AlternatingItemStyle BackColor="#F7F7F7" />
                <Columns>
                    <asp:TemplateColumn Visible="false">
                        <ItemTemplate>
                            <asp:Label ID="ID" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ID")%>' />
                        </ItemTemplate>
                    </asp:TemplateColumn>
                    <asp:BoundColumn DataField="UserName" HeaderText="Nombre de Usuario" />
                    <asp:BoundColumn DataField="FirstName" HeaderText="First Name" />
                    <asp:BoundColumn DataField="LastName" HeaderText="Last Name" />
                    <asp:BoundColumn DataField="Email" HeaderText="Email" />
                    <asp:BoundColumn DataField="Pass" HeaderText="Password" />
                    <asp:TemplateColumn Visible="true" HeaderText="Newsletter" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:CheckBox ID="Newsletter" runat="server" Checked='<%# DataBinder.Eval(Container.DataItem, "Newsletter")%>' />
                        </ItemTemplate>
                    </asp:TemplateColumn>
                    <asp:ButtonColumn Text="[Editar]" HeaderText="Editar" ButtonType="LinkButton" CommandName="cmdEditUser" />
                    <asp:ButtonColumn Text="[Eliminar]" HeaderText="Eliminar" ButtonType="LinkButton"
                        CommandName="cmdDeleteUser" />
                </Columns>
                <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
                <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
                <ItemStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
                <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" Mode="NumericPages" />
                <SelectedItemStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
            </asp:DataGrid>
        </div>
    </asp:Panel>
    <asp:Panel ID="pnlEditor" runat="server" Visible="false">
        <div class="editor">
            <h5>
                Datos del Usuario</h5>
            <p>
                <asp:Label ID="lblId" AssociatedControlID="txtId" runat="server">Codigo Usuario:</asp:Label>
                <asp:TextBox ID="txtId" runat="server" />
            </p>
            <p>
                <asp:Label ID="lblName" AssociatedControlID="txtName" runat="server">Nombre de Usuario:</asp:Label>
                <asp:TextBox ID="txtName" runat="server" />
            </p>
            <p>
                <asp:Label ID="lblFirstName" AssociatedControlID="txtName" runat="server">Nombre:</asp:Label>
                <asp:TextBox ID="txtFirstName" runat="server" />
            </p>
            <p>
                <asp:Label ID="lblLastName" AssociatedControlID="txtName" runat="server">Apellido:</asp:Label>
                <asp:TextBox ID="txtLastName" runat="server" />
            </p>
            <p>
                <asp:Label ID="lblEmail" AssociatedControlID="txtName" runat="server">Email:</asp:Label>
                <asp:TextBox ID="txtEmail" runat="server" />
            </p>
            <p>
                <asp:Label ID="lblNewsletter" AssociatedControlID="txtName" runat="server">NewsLetter:</asp:Label>
                <asp:CheckBox ID="chkNewsletter" runat="server" />
            </p>
            <p>
                <asp:Label ID="lblDescription" AssociatedControlID="txtPassword" runat="server">Password:</asp:Label>
                <asp:TextBox ID="txtPassword" runat="server" />
            </p>
            <p>
                <asp:Label ID="lblRole" AssociatedControlID="ddlRole" runat="server">Tipo de Usuario:</asp:Label>
                <asp:DropDownList ID="ddlRole" runat="server" />
            </p>
        </div>
        <div class="editorbuttons">
            <asp:Button ID="btnSave" Text="Guardar" runat="server" Width="100" OnClick="btnSave_Click" />
            <asp:Button ID="btnCancel" Text="Cancelar" runat="server" Width="100" OnClick="btnCancel_Click" />
        </div>
    </asp:Panel>
</asp:Content>
